package santeclair.connexion.domaine.technique;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author pchaussalet
 */
public class RetourBean extends AbstractRetourBean implements Serializable {

    private static final long serialVersionUID = 1L;

    private String trameExtraite;
    private String fluxComplet;
    private String codeErreurTechnique;
    private String libelleErreurTechnique;
    private Map<String, String> properties;

    public RetourBean() {
        trameExtraite = "";
        fluxComplet = "";
    }

    public String getCodeErreurTechnique() {
        return codeErreurTechnique;
    }

    public void setCodeErreurTechnique(String codeErreurTechnique) {
        this.codeErreurTechnique = codeErreurTechnique;
    }

    public String getLibelleErreurTechnique() {
        return libelleErreurTechnique;
    }

    public void setLibelleRetour(String libelleErreurTechnique) {
        this.libelleErreurTechnique = libelleErreurTechnique;
    }

    public String getFluxComplet() {
        return fluxComplet;
    }

    public void setFluxComplet(String fluxComplet) {
        this.fluxComplet = fluxComplet;
    }

    public void ajouteAuFlux(String donnees) {
        fluxComplet += donnees;
    }

    public String getTrameExtraite() {
        return trameExtraite;
    }

    public void setTrameExtraite(String trameExtraite) {
        this.trameExtraite = trameExtraite;
    }

	public String getPropertiesAsString() {
        StringBuilder result = new StringBuilder();
        for (Map.Entry<String, String> property : properties.entrySet()) {
            result.append(property.getKey() + ":" + property.getValue() + "|");
        }
        return result.toString();
    }

    public void addProperty(String key, String value) {
        if (properties == null) {
            properties = new HashMap<String, String>();
        }
        properties.put(key, value);
    }

    public Map<String, String> getProperties() {
        return properties;
    }

}
